//
//  BlueButtonView.m
//  Project_IOS
//
//  Created by Jeff on 2022/1/17.
//

#import "BlueButtonView.h"
#import <Masonry/Masonry.h>
#import "Color.h"
@interface BlueButtonView ()
@property (nonatomic, strong) UIView *coverView;

@end

@implementation BlueButtonView

- (instancetype)init {
    self = [super init];
    if (self) {
        [self creatUI];
    }
    return self;
}

- (void)creatUI {
    
    [self addSubview:self.button];
    [self.button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    self.button.layer.cornerRadius = 24;
    self.button.layer.masksToBounds = true;
    [self addSubview:self.coverView];
    [self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(0);
    }];
    self.coverView.hidden = true;
}

- (UIButton *)button {
    if (!_button) {
        _button = [UIButton buttonWithType:UIButtonTypeCustom];
        [_button.titleLabel setTintColor:UIColor.whiteColor];
        [_button.titleLabel setFont:[UIFont systemFontOfSize:16]];
        _button.backgroundColor = [Color colorWithHexString:@"#2075FD"];
    }
    return _button;
}

- (UIView *)coverView {
    if (!_coverView) {
        _coverView = [[UIView alloc] init];
        _coverView.backgroundColor = [Color colorWithHexString:@"#FFFFFF"];
        _coverView.alpha = 0.8;
    }
    return _coverView;
}

- (void)setBtnStr:(NSString *)btnStr {
    _btnStr = btnStr;
    [self.button setTitle:_btnStr forState:UIControlStateNormal];
}

- (void)setAvable:(BOOL)avable {
    _avable = avable;
    self.coverView.hidden = avable;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
